import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import registerDto from './dto/register.dto';
import LoginDto from './dto/login.dto';
import { AuthGuard } from '@nestjs/passport';
import { Request } from 'express';
import { Auth } from './decorator/auth.decorator';
import { User } from './decorator/user.decorator';
import { user as UserType } from '@prisma/client';

@Controller('auth')
export class AuthController {
    constructor(private auth:AuthService){}
    @Post('register')
    register(@Body() body:registerDto){
        return this.auth.register(body)
    }
    @Post('login')
    login(@Body() dto:LoginDto){
        return this.auth.login(dto)
    }
    @Get('all')
    @Auth()
    all(@User() user:UserType){
        return user
    }
}
